from rest_framework import viewsets
from rest_framework import filters
from django_filters.rest_framework import DjangoFilterBackend
from .models import Staff
from .serializers import StaffSerializer
from .filters import StaffFilter
# ViewSets define the view behavior.

class StaffViewSet(viewsets.ModelViewSet):
    queryset = Staff.objects.all().order_by('-last_edit_timestamp')
    serializer_class = StaffSerializer

    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    ordering_fields = ('id', 'email')
    search_fields = ('email', 'surname')

    filter_class = StaffFilter



    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)